import 'package:flutter/material.dart';
import 'package:dio/dio.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Button',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyPage(),
    );
  }
}

class MyPage extends StatefulWidget {
  @override
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> {
  String _data = "";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("网络请求实战"),
      ),
      body: Column(
        children: <Widget>[
          FlatButton(
            onPressed: () async{
              Dio dio = new Dio();
              Response res = await dio.get("https://crayfish.elemecdn.com/perf.js@json/sdk-config/WEB://h5.ele.me/msite/");
              print(res.data);
              print(res.data["global"]);
              },
            child: Text("网络请求"),
          )
        ],
      ),
    );
  }
}
